package controller;

import model.User;
import dao.UserDAO;

import java.util.List;

/**
 * 用户控制器
 */
public class UserController {
    private UserDAO userDAO;

    public UserController() {
        userDAO = new UserDAO();
    }

    // 根据ID查询用户
    public User getUserById(String userId) {
        return userDAO.findUserById(userId);
    }

    // 查询所有学生
    public List<User> getAllStudents() {
        return userDAO.findStudents();
    }

    // 添加学生
    public boolean addStudent(User student) {
        try {
            userDAO.addUser(student);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}